package au.com.cgu.RescueU;

public class Registration implements java.io.Serializable {
	private static final long serialVersionUID = 1L;
	private String ID = null;
	private String policyHolder;
	private String policyNumber;
	
	public Registration() {
		super();
	}
	
	public Registration(String inName, String inPolicy) {
		super();
		this.policyHolder = inName;
		this.policyNumber = inPolicy;
		generateID();
	}
	
	public Registration(String inName, String inPolicy, String inID) {
		super();
		this.policyHolder = inName;
		this.policyNumber = inPolicy;
		this.ID = inID;
	}

	public String getPolicyHolder() {
		return policyHolder;
	}
	public void setPolicyHolder(String policyHolder) {
		this.policyHolder = policyHolder;
	}
	public String getPolicyNumber() {
		return policyNumber;
	}
	public void setPolicyNumber(String policyNumber) {
		this.policyNumber = policyNumber;
	}
	
	public void generateID() {
		if (this.policyHolder != null && this.policyHolder.length() > 0 &&
				this.policyNumber != null && this.policyNumber.length() > 0) {
			this.ID = this.policyHolder.hashCode() + ":" + this.policyNumber.hashCode();
		}
	}
	
	public String RegistrationID() {
		if (this.ID != null && this.ID.length() > 0) {
			return this.ID;
		} else {
			generateID();
			return this.ID;
		}
	}
	
	public String getID() {
		return this.RegistrationID();
	}
}